package com.minminaya.source;

public class Algorithm_13 {


    public static class Node {
        int value;
        Node next;
    }

    public static Node reverseHead(Node head) {
        if (head == null) {
            return null;
        }


        Node pre = head;
        Node cur = head.next;
        Node next = null;

        while (cur != null) {
            next = cur.next;//存
            cur.next = pre;//指针指到前面

            //指针前移
            pre = cur;
            cur = next;
        }

        //终点，并且pre为当前位置
        head.next = null;
        head = pre;
        return head;
    }

}
